package org.chw.indicator;
/* *
 * @Author chen
 * @Date 2018/5/25 16:13
 */

import org.chw.rest.FirstRest;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/* *
 * @ClassName AppIndicator
 * @Author chen
 * @Description 应用健康指示器
 * @Date 2018/5/25 16:13
 * @Version 1.0
 **/
@Component
public class AppIndicator implements HealthIndicator {
    public Health health() {
        Map<String, String> details = new HashMap();
        if (FirstRest.canVisitDb) {
            details.put("msg", "yes");
            return new Health.Builder(Status.UP,details).build();
        } else {
            details.put("msg", "no");
            return new Health.Builder(Status.DOWN,details).build();
        }

    }
}
